package com.tuo51.evaluate.domain.etc;

import com.matt.commons.model.Model;
import com.matt.foundation.model.UnionTypeID;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.util.Date;

@Entity
@Data
@Table(name = "tb_mail_record")
@EqualsAndHashCode(callSuper = true)
public class MailRecord extends Model {

    @Column(columnDefinition = " datetime DEFAULT NOW() COMMENT '创建时间' ")
    private Date created = new Date();

    @AttributeOverrides({
            @AttributeOverride(name = "domainId", column = @Column(name ="objectID", nullable = false, length =32, columnDefinition = "varchar(50) COMMENT '导出对象的 id' ")),
            @AttributeOverride(name = "type",column = @Column(name="type", nullable = false,length = 32,columnDefinition = "int default 0 COMMENT '导出类型， 0：能力发展测评， 1：心里行为测评， 2：二宝测评'"))})
    private UnionTypeID typeID;

    @Column(columnDefinition = "varchar(255) COMMENT '静态化文件 URL' ")
    private String staticURL;

    @Column(columnDefinition = "varchar(255) COMMENT '发送地址'")
    private String mailAddress;

    @Column(columnDefinition = "varchar(32) COMMENT '用户'")
    private String staffId;

    @Column(columnDefinition = "longtext COMMENT '邮件内容'")
    private String mailContent;

    @Column(columnDefinition = "varchar(32) COMMENT '发送结果'")
    private String sentResult;

    public static MailRecord of(String staffId, String staticURL, String mailAddress,String mailContent){
        MailRecord record = new MailRecord();

        record.setCreated(new Date());
        record.setStaffId(staffId);
        record.setStaticURL(staticURL);
        record.setMailAddress(mailAddress);
        record.setMailContent(mailContent);

        return record;
    }
}
